#include "Clock.hpp"
#include "Utils.hpp"

using namespace MonsterFactory;

Clock* Clock::instance = NULL;
Clock::Garbo Clock::garbo;

void Clock::Tic() {
  status = TIC;
  gettimeofday(&start, NULL);
}

void Clock::Toc() {
  if (status != TIC) {
    status = NA;
    return;
  }
  status = TOC;
  gettimeofday(&end, NULL);
}

double Clock::GetDuration() {
  if (status != TOC) {
    return 0.0;
  }

  return end.tv_sec-start.tv_sec + (end.tv_usec-start.tv_usec)/1000000.0;
}

